using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class HPChange : MonoBehaviour
{
    public Transform Player;

    public Text HPText;
    public static int HPCurrent;
    public int HPMax;

    Image HP;

    // Start is called before the first frame update
    void Start()
    {
        HP = GetComponent<Image>();
        HPMax = Player.GetComponent<Player>().maxHp;
        HPCurrent = HPMax;
    }

    // Update is called once per frame
    void Update()
    {
        HPCurrent = 0;
        if(GameObject.Find("Player"))
        {
            HPMax = Player.GetComponent<Player>().maxHp;
            HPCurrent = Player.GetComponent<Player>().hp;
        }
        HP.fillAmount = (float)HPCurrent / (float)HPMax;
        HPText.text = HPCurrent.ToString() + "/" + HPMax.ToString();
    }
}
